package gatilhos;

import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.TextureManager;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TextureRegion;

import android.content.Context;

public class Corda extends Gatilho {

	private BitmapTextureAtlas mapaDeTexturas;
	private TextureRegion textura;

	public Corda(int x, int y,Context contexto, TextureManager tm){
		this.x = x;
		this.y = y;
		largura = 64;
		altura = 128;
		
		mapaDeTexturas = new BitmapTextureAtlas(64, 128, TextureOptions.BILINEAR);
		textura = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mapaDeTexturas, contexto, "Gatilho #3.png", 0, 0);
		tm.loadTexture(mapaDeTexturas);
		
		sprite = new Sprite(x, y, textura);
	}

	@Override
	public void atualiza() {
		
	}

	@Override
	public boolean colidiuComCaoGuia(AnimatedSprite spriteCaoGuia) {
		if(spriteCaoGuia.collidesWith(sprite)){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public void posicionaNaCena(int mapx, int mapy) {
		sprite.setPosition((int)x-mapx, (int)y-mapy);
		if(ativado){
			//dbg.drawImage(spriteAtivacao, (int)XAtivacao-mapx, (int)YAtivacao-mapy,(int)XAtivacao+32-mapx, (int)YAtivacao+64-mapy+(int)elasticidade, 0, 0,31, 64, null);
		}else{
			//dbg.drawImage(spriteAtivacao, (int)XAtivacao-mapx, (int)YAtivacao-mapy,(int)XAtivacao+32-mapx, (int)YAtivacao+64-mapy, 0, 0,31, 64, null);
		}
	}

}
